#define _16S1Y_H_
#ifdef _16S1Y_H_

#include "main.h"
#include "font.h"

/* 是否使用SPI,不使用就用软件模拟 */
#define ZK_USE_SPI
/* 快速读取 */
#define FAST_READ

#define ZK_CS               PBout(10)

#ifndef ZK_USE_SPI

#define ZK_CLK              PAout(5)
#define ZK_MOSI             PAout(7)
#define ZK_MISO             PAin(4)

void zk_byte_write(uint8_t cmd);
uint8_t zk_byte_read();
void zk_read(uint8_t *pBuff, uint8_t len);
void zk_write(uint8_t *pBuff, uint8_t len);

#else

#define zk_byte_read        spi1_byte_read
#define zk_byte_write       spi1_byte_write
#define zk_read             spi1_read
#define zk_write            spi1_write

#endif // !ZK_USE_SPI

#ifdef FAST_READ
#define ZK_READ_CMD         0x0B000000
#define SendDummyByte       zk_byte_write(0x00)
#else
#define ZK_READ_CMD         0x03000000
#define SendDummyByte
#endif

void flash_init();
/* 设置字库芯片指针 */
void zk_set_16x16_address(uint16_t text);

/* 获取一份只读点阵 */
uint8_t *zk_get_8x16_font(uint8_t text);
uint8_t *zk_get_5x7_font(uint8_t text);

/* 将点阵读到缓冲区 */
void zk_read_16x16_font(uint8_t *buf, uint16_t text);
void zk_read_8x16_font(uint8_t *buf, uint8_t text);
void zk_read_5x7_font(uint8_t *buf, uint8_t text);

/* 将竖置点阵变为模置点阵 */
void zk_V2H_16x16_font(uint8_t *buf);
void zk_V2H_16x8_font(uint8_t *buf);
#endif
